﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            var name = TextBox1.Text;
            var pwd = TextBox2.Text;

            var sql = string.Format("select * from Users where Name='{0}' and Pwd = '{1}'",name,pwd);
            var sqltable=DbHelper.data(sql);

            if (sqltable.Rows.Count==1)
            {
                var row = sqltable.Rows[0];
                var IsActived = (bool)row.ItemArray[3];
                var IsDeleted = (bool)row.ItemArray[4];

                if (IsDeleted)
                {
                    Label3.Text = "该账号已被删除或注销";
                }
                else if (IsActived)
                {
                    Response.Redirect("Main.aspx");
                }
                else
                {
                    Label3.Text = "该账号已被冻结，请联系客服处理！";
                }
            }
            else
            {
                Label3.Text = "用户名或密码错误！";
            }

        }
    }
}